﻿using MediatR;
using MES.Server.API.Application.Command.Factory_Modeling;
using MES.Server.API.Dto.Factory_Modeling.OutPut;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ReturnValue;

namespace MES.Server.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FactoryModelingController : ControllerBase
    {
        private readonly IMediator mediator;
        public FactoryModelingController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加车间
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddWorkShop(AddWorkShopCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 删除车间信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<ApiResult<int>> DelWorkShop(DelWorkShopCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 获取车间信息列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiPaging<GetWorkShopOutPut>> GetWorkShop([FromQuery]GetWorkShopCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 修改车间信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateWorkShop(UpdateWorkShopCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 添加产线管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddProductionLine(AddProductionLineCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 产线删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> DelProductionLine(DelProductionLineCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 产线信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<GetProductionLineOutPut>> GetProductionLine([FromQuery]GetProductionLineCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 产线信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateProductionLine(UpdateProductionLineCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
    }
}
